clear
capture log close
set more off
set mem 200000

use c:\d\CougarsNLSY\cougars2

gen fem=(SEX==2)
keep if mar1year>0 & mar1year<2011

replace difagemar1=difagemar1*(-1) if fem==1
gen agepos=difagemar1>=0
gen agediffpos=difagemar1*agepos
gen agediffneg=difagemar1*(1-agepos)*(-1)
gen agemar1=mar1year-yearbirth
keep if agediffpos!=.

gen p1=(agediffpos>1&agediffpos<=4)
gen p2=(agediffpos>=5&agediffpos<=7)
gen p3=(agediffpos>=8)
gen n1=(agediffneg>1&agediffneg<=4)
gen n2=(agediffneg>=5&agediffneg<=7)
gen n3=(agediffneg>=8)

gen lhs=(educ<12)
gen hs=(educ>=12&educ<16)
gen coll=(educ==16)
gen adv=(educ>16)
gen hisp=(RACE==1)
gen black=(RACE==2)
gen white=(RACE==3)
tab yearbirth, gen(yb)
gen agem2=agemar1*agemar1

log using Tab2.log, replace

reg AFQT_1 p1 p2 p3 n1 n2 n3 yb* hisp black white agemar1 agem2 hs coll adv if fem==0 [w=wgt], robust
reg AFQT_1 p1 p2 p3 n1 n2 n3 yb* hisp black white agemar1 agem2 hs coll adv if fem==1 [w=wgt], robust


log close





